package com.zhouchao.persistence.enums;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;

/**
 * @Author: zhouchao
 * @Date: 2021/05/11 17:01
 * @Description:
 */
public enum SqlCommandType {
    UNKNOWN("unknown"), INSERT("insert"), UPDATE("update"), DELETE("delete"), SELECT("select"), FLUSH("flush");

    private final static Map<String, SqlCommandType> map = new HashMap<>();

    static {
        Stream.of(SqlCommandType.values()).forEach(type -> {
            map.put(type.code, type);
        });
    }

    SqlCommandType(String code) {
        this.code = code;
    }

    private String code;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public static SqlCommandType getByCode(String code) {
        return map.get(code);
    }
}
